﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using System.Configuration;
using Microsoft.Practices.Unity.Configuration;

namespace Skynet.WPF4
{
    public class ModuleIni : IModule
    {
        [Dependency]
        public IUnityContainer ContainerService { get; set; }
        public void Initialize()
        {
            ConfigureContainer();
        }
        public void ConfigureContainer()
        {
            var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = @".\Modules\WPF4Module.config" };
            var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");
            this.ContainerService.LoadConfiguration(unitySection);
 
        }
    }
}
